package cate.game.activity.crossrank.po;

import cate.common.table.activity.crossrankactivity.row.CrossRankActivityBaseRow;
import cate.game.activity.rank.RoleRankActivity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import easy.java.dev.note.NoteClass;

import java.util.Optional;

@NoteClass("跨服排行榜活动")
public class CrossRankActivity extends RoleRankActivity {
    @Override
    public void onEnter() {
        super.onEnter();
        CrossRankActivityBaseRow baseRow = getBaseRow();
        if(baseRow != null){
            Optional.ofNullable(role.getGame().crossRank.getHandler(baseRow.rankId))
                        .ifPresent(handler -> handler.record(role, rankValue, true));
        }
    }

    @Override
    protected void onPay(long payCents) {

    }

    @Override
    public void onRoleEnd() {
        super.onRoleEnd();
    }

    @JsonIgnore
    @Override
    protected CrossRankActivityBaseRow getBaseRow() {
        return role.getGame().table.crossRankActivity.base.get(configTid());
    }
}
